package com.artisan.admin.model.accountViewModels;

import com.artisan.domain.dto.AccountDto;
import com.artisan.domain.entity.MAccount;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.util.function.Function;

@Data
public class AccountViewModel {
    @ApiModelProperty(value="用户名",required = true,example = "admin")
    private String userName;  // 用户名
    @ApiModelProperty(value="密码",required = true,example = "123456")
    private String password;  // 密码
    @ApiModelProperty(value="省",required = true,example = "省")
    private String provinceName;  // 省
    @ApiModelProperty(value="市",required = true,example = "市")
    private String cityName;  // 市
    @ApiModelProperty(value="区",required = true,example = "区")
    private String areaName;  // 区
    @ApiModelProperty(value="街道",required = true,example = "街道")
    private String streetName;  // 街道
    @ApiModelProperty(value="社区",required = true,example = "社区")
    private String communityName;  // 社区
    @ApiModelProperty(value="角色id",required = true,example = "1")
    private int roleId;  // 角色id

    /**
     * 拷贝方法
     *
     * @return
     */
    public AccountDto convert() {
        return new Function<AccountViewModel, AccountDto>() {
            @Override
            public AccountDto apply(AccountViewModel model) {
                AccountDto dto = new AccountDto();

                //如果有相同的一些属性，也能加上这句
                BeanUtils.copyProperties(model, dto);
                return dto;
            }
        }.apply(this);
    }
}
